﻿using System.ComponentModel.DataAnnotations;
using TrackSystem.Entities.Extensions;
using BootstrapBlazor.Components;

namespace TrackSystem.Entities.Dtos.Channel
{
    public class ChannelDto
    {

        /// <summary>
        /// 统一标识符
        /// </summary>
        [Key]
        [Display(Name = "ID")]
        [AutoGenerateColumn(Order = 1)]
        public int Id { get; set; }

        /// <summary>
        /// 通道名称
        /// </summary>
        [Display(Name = "名称")]
        [AutoGenerateColumn(Order = 10, Filterable = true, Searchable = true)]
        public string? Name { get; set; }

        /// <summary>
        /// 通道描述
        /// </summary>
        [Display(Name = "描述")]
        [AutoGenerateColumn(Order = 20, Filterable = true, Searchable = true)]
        public string? Description { get; set; }

        /// <summary>
        /// 端口通信种类
        /// </summary>
        [Display(Name = "端口类型")]
        [AutoGenerateColumn(Order = 30)]
        public PortCategory PortCategory { get; set; }

        /// <summary>
        /// 通道远程IP地址
        /// </summary>
        [Display(Name = "远程IP")]
        [AutoGenerateColumn(Order = 40)]
        public string? Ip { get; set; }

        /// <summary>
        /// 远程通道端口地址
        /// </summary>
        [Display(Name = "远程端口")]
        [AutoGenerateColumn(Order = 50)]
        public int Port { get; set; }

        /// <summary>
        /// UDP通信方式， 需要知道本地IP地址
        /// </summary>
        [Display(Name = "本地IP")]
        [AutoGenerateColumn(Order = 60)]
        public string? localIp { get; set; }

        /// <summary>
        /// UDP通信方式，需要知道本地通信端口号
        /// </summary>
        [Display(Name = "本地端口")]
        [AutoGenerateColumn(Order = 70)]
        public int localPort { get; set; }

        /// <summary>
        /// 串口通信方式，需要知道本地的通讯串口号
        /// </summary>
        [Display(Name = "串口号")]
        [AutoGenerateColumn(Order = 80)]
        public string? COMn { get; set; }

        /// <summary>
        /// 通信波特率
        /// </summary>
        [Display(Name = "波特率")]
        [AutoGenerateColumn(Order = 90)]
        public int Baudrate { get; set; }

        /// <summary>
        /// 串口参数，类似 “N-8-1”
        /// </summary>
        [Display(Name = "串口参数")]
        [AutoGenerateColumn(Order = 100)]
        public string? SerialParams { get; set; }

        /// <summary>
        /// 通信协议
        /// </summary>
        [Display(Name = "通信协议")]
        [AutoGenerateColumn(Order = 110)]
        public ProtocolEnum Protocol { get; set; }

        /// <summary>
        /// 在MODBU协议下，是否支持21功能
        /// </summary>
        [Display(Name = "支持同时读写")]
        [AutoGenerateColumn(Order = 120)]
        public bool optSupport21Cmd { get; set; }

        /// <summary>
        /// 在MODBU协议下，是否支持3/4功能分离
        /// </summary>
        [Display(Name = "合并3,4功能")]
        [AutoGenerateColumn(Order = 130)]
        public bool optSplit3_4Cmd { get; set; }

        /// <summary>
        /// 通信周期 ms
        /// </summary>
        [Display(Name = "通信周期")]
        [AutoGenerateColumn(Order = 140)]
        public int Interval { get; set; }
    }
}
